package com.kit.data.kitopeso.analysis

import com.google.firebase.messaging.FirebaseMessaging
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.kit.data.kitopeso.KitoApp

import com.kit.data.kitopeso.analysis.libs.FirebaseLib

class KitoFirebaseService : FirebaseMessagingService(){

    override fun onCreate() {
        super.onCreate()
        // Fetch FCM token and set in Adjust SDK
        FirebaseMessaging.getInstance().token
            .addOnCompleteListener { task ->
                if (task.isSuccessful && task.result != null) {
                    FirebaseLib.updateNewToken(KitoApp.getInstance(), task.result)
                }
            }
    }

    override fun onNewToken(token: String) {
        super.onNewToken(token)

        // Receive new FCM token and set in Adjust SDK
        FirebaseLib.updateNewToken(KitoApp.getInstance(),token)
    }

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
    }

}